package practice.iterator;

import java.util.Iterator;

/**
 * @ClassName ComputerCollegeIterator
 * @Description 计算机学院实现iterator,
 * @Author yaoqiang
 * @Date 2020/9/14 16:48
 * @Version 1.0
 */
public class ComputerCollegeIterator implements Iterator {

    Department[] departments;
    int position = 0;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    public ComputerCollegeIterator() {

    }

    @Override
    public boolean hasNext() {
        if (position >= departments.length || departments[position] == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public Object next() {
        Department department = departments[position];
        position++;
        return department;
    }

    @Override
    public void remove() {

    }
}
